package com.github.prontera.util.converter.jackson;

import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * @author Alex
 */
public class OffsetDateToIso8601Serializer extends JsonSerializer<OffsetDateTime> {

	public static final OffsetDateToIso8601Serializer INSTANCE = new OffsetDateToIso8601Serializer();

	@Override
	public void serialize(OffsetDateTime dateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
		 jsonGenerator.writeString(dateTime.format(DateTimeFormatter.ISO_DATE));
	}

}
